//
//  User.m
//  IconPair
//
//  Created by Yangss on 2010-6-26.
//  Copyright 2010 LotusVille. All rights reserved.


#import "User.h"

@implementation User

#pragma mark clear 
+(void) clear{
	[User saveScore:0];
	[User saveWinedLevel:0];
}

#pragma mark get
+(NSString *) name{
	return [[NSUserDefaults standardUserDefaults] stringForKey:kName];
}

+(int) score{
	int score = [[NSUserDefaults standardUserDefaults] integerForKey: kScore];	
	if (score < 0) {
		return 0;
	}
	return score;
}


+(int) winedLevel{
	int winedLevel = [[NSUserDefaults standardUserDefaults] integerForKey: kWindedLevel];	
	if (winedLevel <= 0) {
		return 0;
	}
	return winedLevel;
}

#pragma mark set

+(void) saveName: (NSString *) name{
	[[NSUserDefaults standardUserDefaults] setObject:name forKey:kName];
	[[NSUserDefaults standardUserDefaults] synchronize];
}


+(void) saveScore: (int) score{
	[[NSUserDefaults standardUserDefaults] setInteger:score forKey:kScore];
	[[NSUserDefaults standardUserDefaults] synchronize];
}

+(void) saveWinedLevel: (int) winedLevel
{
	if ([User winedLevel] >= winedLevel) {
		return;
	}
	[[NSUserDefaults standardUserDefaults] setInteger: winedLevel forKey:kWindedLevel];
	[[NSUserDefaults standardUserDefaults] synchronize];
}
@end
